<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <c:if test="#{userBean.student==null}">
            <p:outputLabel value="您还没有登录请点击"/>
            <p:link value="此处" target="_blank" outcome="/util/register.xhtml" />
            <p:outputLabel value=",进行登录"/>
        </c:if>
        <c:if test="#{userBean.student.saccess==null}">
            <p:outputLabel value="对不起没有权限"/>
        </c:if>
        
        <c:if test="#{userBean.student.saccess!=null}">
            
        <h2>文章发布</h2>
        <h:form>
            <p:outputLabel value="文章类型:" />
            <p:selectOneMenu id="selecttype" value="#{userBean.selectType}" style="width:125px">
                <c:forEach items="#{appBean.typeList}" var="type">
                    <f:selectItem itemLabel="#{type.tname}" itemValue="#{type.tid}" />
                </c:forEach>
            </p:selectOneMenu>
 
            <p:stack  expanded="true">
                <p:menuitem value="Home" icon="/image/home.png" url="index.xhtml"/>
            </p:stack>
            <p:outputLabel value="文章题目:"/>
            <p:inputText value="#{userBean.header}" required="true"/>
            <br/>
            <p:editor id="editor" widgetVar="editorWidget" value="#{userBean.text}" width="1200"  required="true"/>

            <h:panelGrid columns="2" style="margin-top: 10px">
                <p:commandButton value="Submit" actionListener="#{userBean.addEssay}" update="display" oncomplete="PF('dlg').show()" icon="ui-icon-disk" />
                <p:commandButton value="Clear" type="button" onclick="PF('editorWidget').clear();" icon="ui-icon-close" />
            </h:panelGrid>

            <p:dialog header="Content" widgetVar="dlg" showEffect="fade" hideEffect="fade">
                <h:outputText id="display" value="#{userBean.text}" escape="false" />
            </p:dialog>
        </h:form> 
            
        </c:if>
        
    </h:body>
</html>

